/*
 * XYCustomNeighborhood.java
 *
 * Created on April 1, 2005, 8:35 AM
 */

package edu.temple.GUS.MMA.Neighborhoods;

import edu.temple.GUS.MMA.DataTypes.*;

/**
 *
 * @author jleong
 */
public class XYCustomNeighborhood extends XYNeighborhood{
    
    private boolean filter[][];

    /** Creates a new instance of XYCustomNeighborhood */
    public XYCustomNeighborhood(int x, int y, boolean filter[][])
    {
        // Define the x and y extend of the neighborhood
        super(x,y);
        this.filter = filter;
    }
    
    /** Creates a new instance of XYCustomNeighborhood */
    public XYCustomNeighborhood(MMAGrid filterGrid)
    {
        // Define the x and y extend of the neighborhood
        super(filterGrid.getX(),filterGrid.getY());
        
        int x = filterGrid.getX();
        int y = filterGrid.getY();
        float noData = filterGrid.getNoData();
        
        // Create a customed filter
        filter = new boolean[y][x];
        
        for (int j=0; j<=y; j++)
            for (int i=0; i<=x; i++)
            {
                if ( filterGrid.getElement(i,j) == noData )
                    filter[j][i] = false;
                else
                    filter[j][i] = true;
            }
    }
    
    public boolean getFilterElement(int x, int y) { return filter[y][x];}
}
